package com.qingcheng.consumer;

import com.qingcheng.service.index.IndexService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;

public class DelIndexMessageConsumer implements MessageListener {

    @Autowired
    private IndexService indexService;

    /**
     * 从rabbitmq中获取数据，并将索引数据存入elasticsearch中
     * @param message
     */
    @Override
    public void onMessage(Message message) {
        try {
            String spuId = new String(message.getBody());
            indexService.putawayToElasticSearch(spuId);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }



}
